package com.cdel.akka.ask;

import akka.actor.UntypedActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;

public class Printer extends UntypedActor {

	private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);

	public static enum Msg{
		DONE, CLOSE;
	}

	@Override
	public void onReceive(Object msg) throws Throwable {
		if(msg instanceof Integer){
			System.out.println("Printer:" + msg);
		}
		if(msg == Msg.CLOSE){
			log.info("i will shutdown");
			getSender().tell(Msg.CLOSE, getSelf());
			getContext().stop(getSelf());
		}else{
			unhandled(msg);
		}
	}

}
